<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>语法糖注册组件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <cpn1></cpn1>
      <cpn2></cpn2>
    </div>

    <script>
      // 语法糖注册全局组件
      Vue.component("cpn1", {
        template: `
        <div>
            <h1>全局组件</h1> 
            <p>嘿嘿嘿嘿嘿嘿</p>
        </div>
        `,
      });
      //创建Vue实例,得到 ViewModel
      var app = new Vue({
        el: "#app",
        data: {},
        methods: {},
        // 语法糖注册局部组件
        components: {
          cpn2: {
            template: `
              <div>
                <h1>局部组件</h1> 
                <p>嘿嘿嘿嘿嘿嘿</p>
              </div>
            `,
          },
        },
      });
    </script>
  </body>
</html>
